package hhm.javamode.iterator.phone;

import java.util.List;

public class PlanBIterator implements Iterator {
	private int pointer = 0;

	private List<Object> list;

	public PlanBIterator(List list) {
		this.list = list;
	}

	@Override
	public boolean hasNext() {
		return this.pointer < list.size() ? true : false;
	}

	@Override
	public Object next() {
		if (this.pointer < list.size()) {
			Object obj = list.get(pointer);
			pointer++;

			Phone phone = (Phone) obj;
			if (phone.getPrice() >= 2000) {
				phone.setPrice(phone.getPrice() * 0.4);
				return phone;

			} else {
				phone.setPrice(phone.getPrice() * 0.9);
				return phone;
			}
		}
		return null;
	}

}
